﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;


namespace WindowsFormsApplication3
{
    public partial class PatientForm : Form
    {
        public PatientForm()
        {
            InitializeComponent();
        }



        private void button1_Click(object sender, EventArgs e)
        {
            Patient p = new Patient();

            {
                p.Name = textBox1.Text;
                p.SurName = textBox2.Text;
                //string Name123 = p.Name;
            }
            //MessageBox.Show("1");

            Form1 f = new Form1();
            //f.dataGridView_Rows_Add(p);

            // Печать в файл
            {
                string idd = "";
                string[] str1 = File.ReadAllLines(".\\..\\..\\Patient_text.txt");

                if (str1.Length == 0)
                {
                    p.id = 1;
                }
                else
                {
                    idd = str1[str1.Length - 1].Substring(0, str1[str1.Length - 1].IndexOf(","));
                    p.id = Convert.ToInt32(idd);
                    p.id++;
                }
                string str = p.id.ToString() + ",";
                str += p.Name + ",";
                File.AppendAllText(".\\..\\..\\Patient_text.txt", str + "\n");
            }
        }

        private void PatientForm_Load(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }





          
        



      
    }



}
